package com.authine.cloudpivot.ext.controller;

/**
 * Copyright (C), 2015-2020, XXX有限公司
 * FileName: Test
 * Author:   Administrator
 * Date:     2020/1/30 21:55
 * Description: 1
 * History:
 * <author>          <time>          <version>          <desc>
 * 作者姓名           修改时间           版本号              描述
 */

import com.alibaba.dubbo.common.utils.StringUtils;
import com.alibaba.fastjson.JSON;
import com.authine.cloudpivot.web.Utils.HkUtils;
import com.authine.cloudpivot.web.Utils.HttpClientUtils;
import com.authine.cloudpivot.web.api.vo.FeverClinicSurveyInfoVo;
import io.swagger.util.Json;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.apache.commons.lang3.time.DateUtils;
import org.springframework.security.crypto.factory.PasswordEncoderFactories;
import org.springframework.security.crypto.password.PasswordEncoder;

import javax.crypto.Cipher;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.math.BigDecimal;
import java.util.*;

/**
 * 〈一句话功能简述〉<br>
 * 〈1〉
 *
 * @author Administrator
 * @create 2020/1/30
 * @since 1.0.0
 */
public class Test {
    /**
     * 随机生成密码
     *
     * @param length 密码的长度
     * @return 最终生成的密码
     */
    public static String generatePassword(int length) {
        // 最终生成的密码
        String password = "";
        Random random = new Random();
        for (int i = 0; i < length; i++) {
            // 随机生成0或1，用来确定是当前使用数字还是字母 (0则输出数字，1则输出字母)
            int charOrNum = random.nextInt(2);
            if (charOrNum == 1) {
                // 随机生成0或1，用来判断是大写字母还是小写字母 (0则输出小写字母，1则输出大写字母)
                int temp = random.nextInt(2) == 1 ? 65 : 97;
                password += (char) (random.nextInt(26) + temp);
            } else {
                // 生成随机数字
                password += random.nextInt(10);
            }
        }
        return password;
    }


    public static void main(String[] args) {
//        PasswordEncoder delegatingPasswordEncoder = PasswordEncoderFactories.createDelegatingPasswordEncoder();
//        List<String> list = new ArrayList<>();
//        for(int i = 0; i < 9; i ++){
//            String password = generatePassword(8);
//            System.out.println(password);
//            list.add(password);
//        }
//        for (String pwd : list){
//            System.out.println(delegatingPasswordEncoder.encode(pwd));
//        }
//        boolean matches = delegatingPasswordEncoder.matches(password, pwd);




    }


    private static void  testss(){
        List<String> list = getList();
        String url  = "http://220.174.210.180/api/api/hkgy/pharmacyControl?objectId=%s";

        long ls = System.currentTimeMillis();
        System.out.println("开始 "+ls);
        list.parallelStream().forEach(ac ->{


            HttpClientUtils.doGet(String.format(url,ac ));

        });

        System.out.println("结束 "+ (System.currentTimeMillis()-ls));


    }

    private static List<String> getList (){
        File file = new File("D:\\test.txt");

        List<String> list = new ArrayList<>();
        try{
            BufferedReader br = new BufferedReader(new FileReader(file));//构造一个BufferedReader类来读取文件
            String s = null;
            while((s = br.readLine())!=null){//使用readLine方法，一次读一行

                list.add(s);
            }
            br.close();
        }catch(Exception e){
            e.printStackTrace();
        }


        return  list;
    }

}
